#include "accesscount.h"

namespace MCCommon
{

AccessCount::AccessCount() 
: fpAccessCount(0) 
{
}

AccessCount::~AccessCount()
{
}

void AccessCount::Decrease() 
{
    if (fpAccessCount) 
    {
        (*fpAccessCount)--;
        if (*fpAccessCount == 0) 
        {
            delete fpAccessCount;
            fpAccessCount = 0;
        }
    }
}

void AccessCount::Increase() 
{
    if ( fpAccessCount ) 
    {
        (*fpAccessCount)++;
    } 
    else 
    {
        fpAccessCount = new int;
        *fpAccessCount = 1;
    }
}

int AccessCount::GetCount() 
{
    return fpAccessCount ? *fpAccessCount : 0;
}

}// end of namespace MCXML_NAMESPACE.